//
//  ConfirmCalendarCollectionViewCell.m
//  SIqICalendar
//
//  Created by sunjiawen on 17/3/16.
//  Copyright © 2017年 sjw. All rights reserved.
//

#import "ConfirmCalendarCollectionViewCell.h"
#import "JWScheduleModel.h"
@implementation ConfirmCalendarCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews
{
    //    self.backgroundColor = [UIColor clearColor];
    //日期
    self.dateTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    self.dateTextLabel.backgroundColor = [UIColor clearColor];
    self.dateTextLabel.font = [UIFont systemFontOfSize:defaultFont + 2];
    self.dateTextLabel.textColor = [UIColor blackColor];
    self.dateTextLabel.textAlignment = NSTextAlignmentCenter;
    self.dateTextLabel.numberOfLines = 0;
    [self.contentView addSubview:self.dateTextLabel];
    
    [self.dateTextLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.centerX);
        make.top.equalTo(5);
    }];
    
    CGFloat turnNameLabelSize = 20;
    //轮班名称
    self.turnNameTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, turnNameLabelSize, turnNameLabelSize)];
    self.turnNameTextLabel.backgroundColor = [UIColor clearColor];
    self.turnNameTextLabel.font = [UIFont boldSystemFontOfSize:12];
    self.turnNameTextLabel.textColor = [UIColor whiteColor];
    self.turnNameTextLabel.textAlignment = NSTextAlignmentCenter;
    self.turnNameTextLabel.numberOfLines = 0;
    self.turnNameTextLabel.layer.cornerRadius = turnNameLabelSize/2.0;
    self.turnNameTextLabel.layer.masksToBounds = NO;
    [self.contentView addSubview:self.turnNameTextLabel];
    
    [self.turnNameTextLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.dateTextLabel.centerX);
        make.bottom.equalTo(self.bottom).offset(-5);
        make.height.equalTo(turnNameLabelSize);
        make.width.greaterThanOrEqualTo(turnNameLabelSize);
    }];
    
    
    self.todayClickImageView = [[UIImageView alloc]init];
    self.todayClickImageView.image = [UIImage imageNamed:@"cursor8"];
    self.todayClickImageView.hidden = YES;
    [self.contentView addSubview:self.todayClickImageView];
    
    self.selectImageView = [[UIImageView alloc]init];
    self.selectImageView.image = [UIImage imageNamed:@"cursor6"];
    self.selectImageView.hidden = YES;
    [self.contentView addSubview:self.selectImageView];
    
    [self.todayClickImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(0);
    }];
    
    [self.selectImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(0);
    }];
    
}


- (void)setDataModel:(JWScheduleModel *)dataModel {
    if (dataModel) {
        self.turnNameTextLabel.text = dataModel.scheduleName;
        self.turnNameTextLabel.layer.backgroundColor = dataModel.scheduleColor.CGColor;
        
    }else {
        
        self.turnNameTextLabel.text = @"无";
        self.turnNameTextLabel.layer.backgroundColor = [UIColor lightGrayColor].CGColor;
        
    }
    
}
@end
